home *** CD-ROM | disk | FTP | other *** search
/ Disc to the Future 2 / Disc to the Future Part II Programmer's Reference (Wayzata Technology)(6013)(1992).bin / MAC / OTHER_LA / YERK__ / TOOLBOX_ / RADIO < prev    next >
Text File  |  1990-11-28  |  2KB  |  63 lines

  1. \ radioSet groups a set of item numbers as a set of radio buttons
  2. \  7/24/85  cbd Changed on: and off: messages to put:
  3. \  7/24/85  cbd Added theDialog as an ivar
  4. \  5/23/90    rfl    Class Radio added for general radio buttons. RadioSet is for
  5. \                dialogs
  6. \            rfl    RadioSet stores the selected cell for use when dialog is newed
  7. \ 11\28\90    rfl added getItem: in radioset
  8.  
  9. \ general Radio button class
  10. :CLASS Radio <super ordered-col
  11.     int     who-is-on
  12.  
  13. :M GET: get: who-is-on ;M
  14.  
  15. :M OFF: { ind - } 0 put: [ ind at: self ] ;M
  16.  
  17. :M ON:  { ind - } get: who-is-on off: self 1 put: [ ind at: self ]
  18.         ind put: who-is-on ;M
  19.  
  20. ( myctl -- )
  21. :M clickedOn: indexOf: self IF on: self THEN ;M
  22.  
  23. :M INIT: { ind - } size: self 0 do i off: self loop 1 put: [ ind at: self ]
  24.         ind put: who-is-on ;M
  25.  
  26. ( a1 a2... n -- )
  27. :M ACTIONS:  dup size: self > classErr" 129
  28.      0 do  actions: [ size: self 1- i - at: self ] loop
  29.      ;M
  30.  
  31. :M hilite: { on/off -- } limit 0 DO on/off hilite: [ i at: self ] LOOP ;M
  32.  
  33. ;CLASS
  34.  
  35. \ for use in dialogs
  36. :CLASS RadioSet  <Super byteCol
  37.  
  38.     Var        theDialog
  39.     int        SelectedCtl
  40.  
  41.     \ ( dialog -- )  associate this radio set with a Dialog
  42.     :M  INIT:  put: theDialog    ;M
  43.  
  44.     \ ( item# -- )  select radio button for item#
  45.     :M  SELECT: { item# -- }  size: self 0
  46.         DO  0  I at: Self   put: [ obj: theDialog ]
  47.         LOOP  1 item#  put: [ obj: theDialog ]  ;M
  48.  
  49.     \ ( -- item# )  return the radio button that was selected
  50.     :M  GET: { -- item# } size: self 0
  51.         DO  I at: self  get: [ obj: theDialog ]
  52.             IF I at: self leave THEN
  53.         LOOP    ;M
  54.  
  55.     :M  SET: get: selectedCtl select: self ;M
  56.  
  57.     :M  PUT: ( item# --) put: selectedCtl ;M
  58.  
  59.     :M  GETITEM: get: selectedCtl ;M
  60.  
  61. ;CLASS
  62.  
  63.